package com.blockmeta.bbs.businesslibrary.base.eventbus;

import com.blankj.utilcode.util.LogUtils;

import org.greenrobot.eventbus.EventBus;

public class EventBusBase {
    protected EventBus m_eventBus;

    public EventBusBase() {
        m_eventBus = new EventBus();
    }

    private EventBus getMyEventBus() {
        return m_eventBus;
    }

    public void register(Object subscriber)
    {
        if(!getMyEventBus().isRegistered(subscriber))
        {
            getMyEventBus().register(subscriber);
        }else {
            LogUtils.d("eventbus", "already register");
        }
    }

    public void unregister(Object subscriber)
    {
        getMyEventBus().unregister(subscriber);
    }

    public boolean isRegistered(Object subscriber)
    {
        return getMyEventBus().isRegistered(subscriber);
    }

    public void post(Object event)
    {
        getMyEventBus().post(event);
    }

    public void postSticky(Object event)
    {
        getMyEventBus().postSticky(event);
    }
}
